package test2;
//向上转型
class Animal{
    public String name="hello";
    public int age;


    public void eat(){
        System.out.println(name+"eat()");

    }
    public Animal(String name,int age){
        this.name=name;
        this.age=age;
    }
}
class Dog extends Animal{

    @Override
    public void eat(){
        System.out.println(name+"狼吞虎咽的吃");

    }



    public Dog(String name,int age){
        super(name,age);

    }

}
class Bird extends Animal{
    public String wing;
    public String name;//null
    public Bird(String name,int age,String wing){
        super(name,age);
        this.wing=wing;
    }
    public void fly(){
        System.out.println(name+"fly()");
    }
}
public class Test2 {
    public static void main(String[] args) {
        Animal animal=new Dog("haha",19); //向上转型【父类引用 引用子类对象】
        animal.eat();
       // System.out.println(animal.wing);
    }


}
